Object-oriented programming languages organize ideas by classes, which are data structures composed of both variables and methods. Certain object-oriented programming languages, such as Java, may enable one class to be built upon or extended by another class (subclass) which inherits the features of the class that is being built upon. In addition to acquiring features, the subclass can override methods defined in the acquired features; thus, there can be multiple classes that define a method with the same name but with different functionality. In such a case, the method carried out depends on the class of the of the object (i.e. class representation) that receives the call for execution of the method. As a result, such a method call is not static as it may not be known during compiling of the computer program code which class will actually call the method; thus such a method call is considered to be a virtual call.
Computer program code is compiled for implementation, which involves reading the program code, analyzing the semantic form for errors, optimizing the code to reduce cost during execution and translating the code into a language suitable for execution. During compiling, the definition of classes are incorporated into the compiled code as they are encountered. During the optimizing stage, code is simplified to reduce execution time using known techniques such as trying to present the code in static form by converting virtual calls to direct method calls. Such known techniques generally attempt to perform whole program analysis where all relationships between classes (represented by a class hierarchy) and all relationships between methods (represented by call graphs) are known.
The computer program code may be compiled such that new classes may be dynamically incorporated during execution and the methods from the newly incorporated classes may be carried out. In this case, the class hierarchy and call graphs can change between compiling and execution. The effect of this may be, for example, that variables are altered during execution of the program code by a class that was not incorporated when a particular method was compiled. Further, classes are only known after they have been incorporated. Thus, known techniques based on an assumption of a static class hierarchy and static call graphs are not valid for computer program code that is dynamically compiled.